<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    // 生成器其实就是一个特殊的函数
    // 异步编程 纯回调函数
    function* gen() {
        console.log("hello generator");
    }
    let g = gen();
    g.next();


    function* gen1() {
        yield 1;
        yield '一只没有耳朵';
        yield '一只没有尾巴';
    }
    for (let value of gen1()) {
        console.log(value);
    }
    let g1 = gen1();
    console.log(g1.next());
    console.log(g1.next());
    console.log(g1.next());
    console.log(g1.next());

</script>

</html>